package com.test;

import cn.hutool.core.date.DateUtil;
import net.minidev.json.JSONObject;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class Main {

    public static void main(String[] args) {
        //List<DateUtils.Range> ranges = DateUtils.splitToMonths(DateUtil.parse("20220104", "yyyyMMdd"), DateUtil.parse("20230104", "yyyyMMdd"));
       /*ranges.stream().forEach(System.out::println);
        System.out.println("////////////////////////");
        Date start = DateUtil.offsetDay(DateUtil.beginOfYear(new Date()),3);
        Date end = new Date();
        List<DateUtils.Range>  DateRangeList = DateUtils.splitToMonths(start,end);

        DateRangeList.stream().forEach( item->{
            System.out.println("item = " + item);
        });*/
        List<Long> beginDateList = null;
        List<Long> endDateList = null;
        TimeCutUtil.getIntervalTimeByMonth(DateUtil.parse("20220104", "yyyyMMdd").getTime(),DateUtil.parse("20230104", "yyyyMMdd").getTime(),beginDateList,endDateList);
        beginDateList.stream().forEach(aLong -> {
            Calendar instance = Calendar.getInstance();
            instance.setTimeInMillis(aLong);
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            simpleDateFormat.format(instance.getTime());
            System.out.println("simpleDateFormat = " + simpleDateFormat);
        });

        endDateList.stream().forEach(aLong -> {
            Calendar instance = Calendar.getInstance();
            instance.setTimeInMillis(aLong);
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            simpleDateFormat.format(instance.getTime());
            System.out.println("simpleDateFormat = " + simpleDateFormat);
        });



    }
}
